CURRENT_FILES=$(wildcard *.cpp)

MY_BASE_DIR=/home/gonghuan

MY_PUBLIC_DIR=$(MY_BASE_DIR)/search/public
MY_PUBLIC_FILE=$(wildcard $(MY_PUBLIC_DIR)/*.cpp)

MY_DOM_DIR=$(MY_BASE_DIR)/search/dom
MY_DOM_FILE=$(wildcard $(MY_DOM_DIR)/*.cpp)

PTHREAD_LIB=-lpthread

FILES=$(CURRENT_FILES) $(MY_PUBLIC_FILE) $(MY_DOM_FILE)

ALL_INCL=-I. -I$(MY_PUBLIC_DIR) -I$(MY_DOM_DIR)

LIBS=$(PTHREAD_LIB)

OPR=-g -Wall
INLINE=-fkeep-inline-functions
CC=g++
CFLAGS=$(OPR) $(INLINE)
OBJ=$(FILES:.cpp=.o)

TARGET=a.out

ALL:$(OBJ)
	rm -rf $(TARGET)
	$(CC) -o $(TARGET) $? $(LIBS)

$(OBJ):%.o:%.cpp
	$(CC) $(ALL_INCL) -c $(CFLAGS) $< -o $@

.PHONY:
clean:
	-rm -rf ./$(TARGET) $(MY_PUBLIC_DIR)/*.o $(MY_DOM_DIR)/*.o ./*.o
